package com.example.myapplication01.mvp.presenter;

import android.content.Context;

import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication01.base.BasePresenter;
import com.example.myapplication01.mvp.model.MainModel;
import com.example.myapplication01.mvp.view.MainView;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @user xunua
 * @email  xunua@outlook.com
 * @creat time 2020/4/10 17:13
 */

public class MainPresenter extends BasePresenter<MainView,MainModel> {

    public MainPresenter(MainView mainView) {
        super(mainView);
        baseModel=new MainModel();
    }

    public List<String> update(){
        return baseModel.getUpdateAdapter();
    }
    public void getRequest(){
        baseModel.getRequest().enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                mView.loginSuccess(response.body());
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                mView.loginError("请求失败:"+call.request().url());
            }
        });
    }
}
